/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author msc
 */
@Entity
@Table(name = "Salary")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Salary.findAll", query = "SELECT s FROM Salary s"),
    @NamedQuery(name = "Salary.findBySalaryId", query = "SELECT s FROM Salary s WHERE s.salaryId = :salaryId"),
    @NamedQuery(name = "Salary.findBySettingDate", query = "SELECT s FROM Salary s WHERE s.settingDate = :settingDate"),
    @NamedQuery(name = "Salary.findByMinSalaryAmount", query = "SELECT s FROM Salary s WHERE s.minSalaryAmount = :minSalaryAmount")})
public class Salary implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "SalaryId")
    private Integer salaryId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SettingDate")
    @Temporal(TemporalType.DATE)
    private Date settingDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MinSalaryAmount")
    private long minSalaryAmount;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "salaryId")
    private Collection<Position> positionCollection;

    public Salary() {
    }

    public Salary(Integer salaryId) {
        this.salaryId = salaryId;
    }

    public Salary(Integer salaryId, Date settingDate, long minSalaryAmount) {
        this.salaryId = salaryId;
        this.settingDate = settingDate;
        this.minSalaryAmount = minSalaryAmount;
    }

    public Integer getSalaryId() {
        return salaryId;
    }

    public void setSalaryId(Integer salaryId) {
        this.salaryId = salaryId;
    }

    public Date getSettingDate() {
        return settingDate;
    }

    public void setSettingDate(Date settingDate) {
        this.settingDate = settingDate;
    }

    public long getMinSalaryAmount() {
        return minSalaryAmount;
    }

    public void setMinSalaryAmount(long minSalaryAmount) {
        this.minSalaryAmount = minSalaryAmount;
    }

    @XmlTransient
    public Collection<Position> getPositionCollection() {
        return positionCollection;
    }

    public void setPositionCollection(Collection<Position> positionCollection) {
        this.positionCollection = positionCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (salaryId != null ? salaryId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Salary)) {
            return false;
        }
        Salary other = (Salary) object;
        if ((this.salaryId == null && other.salaryId != null) || (this.salaryId != null && !this.salaryId.equals(other.salaryId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entities.Salary[ salaryId=" + salaryId + " ]";
    }
    
}
